package com.eric.rabbitmq.client;

import java.util.HashMap;

/**
 * @author chenw-i
 * @version 1.0.0
 * @ClassName Application.java
 * @Description TODO
 * @createTime 2020年07月30日 15:23:00
 */
public class Application {

    /**
     * @param args
     * @throws Exception
     */
    public static void main(String[] args) throws Exception{
        /*
        * 需要时限创建 vhost /test
        * 命令如下：
        *   rabbitmqctl add_vhost /testhost
        *   rabbitmqctl set_permissions -p /testhost admin ".*" ".*" ".*"
        *
        * 具体的命令参数说明可以参考  工程下的readme文件
        * */
        QueueConsumer consumer = new QueueConsumer(Config.TOPIC_EXCHANGE);
        Thread consumerThread = new Thread(consumer);
        consumerThread.start();

        QueueProduct producer = new QueueProduct(Config.TOPIC_EXCHANGE);

        long times = 10;

        for (int i = 0; i < times; i++) {
            HashMap message = new HashMap();
            message.put("message number", i);
            producer.sendMessage(message);
            System.out.println("Message Number "+ i +" sent.");
        }

    }
}
